package org.finir.fakturisanje.persistence.beans;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import org.finir.fakturisanje.persistence.Faktura;
import org.finir.fakturisanje.persistence.Komitent;
import org.finir.fakturisanje.persistence.Preduzece;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;

@Entity
@Name("komitent")
@Scope(ScopeType.PAGE)
public class KomitentBean implements Komitent, Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * 
	 */

	private Long id;
	private String naziv;
	private String mesto;
	private String adresa;
	private String ziroRacun;
	private String JIB;
	private String JMB;
	private String telefon;
	private Preduzece preduzece;

	@ManyToOne(targetEntity = PreduzeceBean.class)
	public Preduzece getPreduzece() {
		return preduzece;
	}

	public void setPreduzece(Preduzece preduzece) {
		this.preduzece = preduzece;
	}

	private List<Faktura> fakture;

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.koitent#getFakture()
	 */
	@OneToMany(targetEntity = FakturaBean.class, cascade = CascadeType.ALL, mappedBy = "komitent")
	public List<Faktura> getFakture() {
		return fakture;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.koitent#setFakture(java.util.List)
	 */
	public void setFakture(List<Faktura> fakture) {
		this.fakture = fakture;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.koitent#getId()
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Long getId() {
		return id;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.koitent#setId(java.lang.Long)
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.koitent#getNaziv()
	 */
	public String getNaziv() {
		return naziv;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.koitent#setNaziv(java.lang.String)
	 */
	public void setNaziv(String naziv) {
		this.naziv = naziv;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.koitent#getMesto()
	 */
	public String getMesto() {
		return mesto;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.koitent#setMesto(java.lang.String)
	 */
	public void setMesto(String mesto) {
		this.mesto = mesto;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.koitent#getAdresa()
	 */
	public String getAdresa() {
		return adresa;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.koitent#setAdresa(java.lang.String)
	 */
	public void setAdresa(String adresa) {
		this.adresa = adresa;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.koitent#getZiroRacun()
	 */
	public String getZiroRacun() {
		return ziroRacun;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.koitent#setZiroRacun(java.lang.String)
	 */
	public void setZiroRacun(String ziroRacun) {
		this.ziroRacun = ziroRacun;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.koitent#getJIB()
	 */
	public String getJIB() {
		return JIB;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.koitent#setJIB(java.lang.String)
	 */
	public void setJIB(String jib) {
		JIB = jib;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.koitent#getJMB()
	 */
	public String getJMB() {
		return JMB;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.koitent#setJMB(java.lang.String)
	 */
	public void setJMB(String jmb) {
		JMB = jmb;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.koitent#getTelefon()
	 */
	public String getTelefon() {
		return telefon;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.koitent#setTelefon(java.lang.String)
	 */
	public void setTelefon(String telefon) {
		this.telefon = telefon;
	}

	@Override
	public int hashCode() {
		int hash = 0;
		hash += (id != null ? id.hashCode() : 0);
		return hash;
	}

	@Override
	public boolean equals(Object object) {
		// TODO: Warning - this method won't work in the case the id fields are
		// not set
		if (!(object instanceof KomitentBean)) {
			return false;
		}
		KomitentBean other = (KomitentBean) object;
		if ((this.id == null && other.id != null)
				|| (this.id != null && !this.id.equals(other.id))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return naziv + " id=" + id;
	}

}
